<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/page/common/jsptag.jsp"%>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="<%=request.getContextPath() %>/bg/css/bg.css" type="text/css" />
    <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.7.1.min.js"></script>
    <style type="text/css">
        label {
            font-size: 12px;
            font-weight: bold;
            text-transform: uppercase;
            display: block;
            text-align: center;
            clear: both;
        }
    </style>
    <script type="text/javascript">
        function closeWin() {
            // 返回给父窗口的值
            window.returnValue = 1;

            window.opener = null;
            window.open('','_self');
            window.close();
        }
        function delRelFilmType(filmId, starId) {
			$.ajax({type:'POST', url:'delRelFilmStar.html', data:'filmId=' + filmId + '&starId=' + starId});
            var starDiv = $("#star" + starId);
            starDiv.remove();
        }

        function load(filmId) {
            $.ajax({type:'get', url:'listSelectFilmType.html?filmId=' + filmId, success:function(data) {
                $(data).find("param").each(function(){
                    var id = $(this).attr("id");
                    var typename = $(this).attr("typename");
                    var checked = $(this).attr("checked");

                    var input = document.createElement("input");
                    input.type = 'checkbox';
                    input.name = 'filmtypeId';
                    input.value = id;
                    if (checked == 'checked') input.checked = true;
                    input.onclick = function () {
                        if (input.checked == true) {
                            $.ajax({type:'POST', url:'relFilmType.html', data:'filmId=' + filmId + '&filmTypeId=' + id});
                        } else {
                            $.ajax({type:'POST', url:'delFilmTypeByFilmId.html', data:'filmId=' + filmId + '&filmTypeId=' + id});
                        }
                    }

                    $("#filmTypeTd").append(input);
                    $("#filmTypeTd").append(typename);
                });
            }});
        }
    </script>
</head>
<body onload="load(${film.filmId});">
    <div id="listDiv">
        <table id="filmTable">
            <tr>
                <th>名称</th>
                <th>值域</th>
            </tr>
            <tr>
                <td><label>电影名称</label></td>
                <td><input type="text" value="${film.filmName}"></td>
            </tr>
            <tr>
                <td><label>播放次数</label></td>
                <td><input type="text" size="6" value="${film.playNum}"></td>
            </tr>
            <tr>
                <td><label>电影主演</label></td>
                <td>
                	<c:forEach items="${film.starList}" var="star">
                        <div id="star${star.id}" style="display: inline;">
                			<span>${star.starName}</span>
                			<a href="javascript:void(0);" onclick="delRelFilmType(${film.filmId}, ${star.id});">
                				<img src="/images/icns/symbol_multiplication.gif" />
                			</a>
                        </div>
                	</c:forEach>
                </td>
            </tr>
            <tr>
                <td><label>电影类型</label></td>
                <td id="filmTypeTd">
                </td>
            </tr>
            <tr>
                <td><label>相关标签</label></td>
                <td><input type="text" size="85" value="${film.tags}"></td>
            </tr>
            <tr>
                <td><label>电影简介</label></td>
                <td><textarea rows="3" cols="100">${film.filmIntroduce}</textarea></td>
            </tr>
        </table>

        <div id="pannel">
            <a href="javascript:void(0);">更新</a>
            <a href="javascript:closeWin();">关闭</a>
        </div>
    </div>
</body>
</html>